package com.gklyj.controller.qiuzhi;

import com.gklyj.pojo.User;
import com.gklyj.pojo.Zixun;
import com.gklyj.service.userService;
import com.gklyj.service.zixunService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
@Transactional
public class Qz_indexController {

    @Autowired
    zixunService zixunService;

    @Autowired
    userService userService;

    //求职者登录成功后在首页列出公告栏资讯信息
    @GetMapping("/qzPageData")
    @ResponseBody
    public List<Zixun> initqzPageZixun(){
        List<Zixun> zixunList =  zixunService.list();
       return zixunList;
    }

    //跳转首页
    @GetMapping("/toQzIndex")
    public String toQzIndex(){
        return "qiuzhi/qz-index";
    }

    //跳转岗位申请页面
    @GetMapping("/toGwsqIndex")
    public String toGwsqIndex(){
        return "qiuzhi/qz-gwsq";
    }
    //跳转正在申请页面
    @GetMapping("/toWdsqIndex")
    public ModelAndView toWdsqIndex(){
        ModelAndView modelAndView = new ModelAndView("qiuzhi/qz-wdsq");
        return modelAndView;
    }

    //跳转申请结果页面
    @GetMapping("/toWdsqIndex1")
    public ModelAndView toWdsqIndex1(){
        ModelAndView modelAndView = new ModelAndView("qiuzhi/qz-wdsq1");
        return modelAndView;
    }
    //跳转联系反馈页面
    @GetMapping("/toLxfkIndex")
    public String toLxfkIndex(){
        return "qiuzhi/qz-lxfk";
    }

    //跳转个人中心页面
    @GetMapping("/toQzCenter")
    public String toQzCenter(HttpServletRequest request,Model model){
        Object username = request.getSession().getAttribute("username");
        User user = userService.findUserByUsername(String.valueOf(username));
        model.addAttribute("user",user);
        return "qiuzhi/qz-center";
    }
}
